package it.andreaartuso.paletta.widget;

import it.andreaartuso.paletta.R;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;

public class ButtonLikeLinearLayout extends LinearLayout {

	int level;
	int bkg_resid_selected;
	int bkg_resid_deselected;
	int bkg_resid_highlighted;
	
	public ButtonLikeLinearLayout(Context context) {
		super(context);
	}
	
	public ButtonLikeLinearLayout(Context context, AttributeSet attrs) {
		super(context, attrs);
	}
	
	public void init(int level){
		this.level = level;
		this.bkg_resid_selected=R.color.lvlsel;

		switch (level) {
			case 0:  bkg_resid_deselected=R.color.lvl0; break;
			case 1:  bkg_resid_deselected=R.color.lvl1; break;
	        case 2:  bkg_resid_deselected=R.color.lvl2; break;
	        case 3:  bkg_resid_deselected=R.color.lvl3; break;
	        case 4:  bkg_resid_deselected=R.color.lvl4; break;
	        case 5:  bkg_resid_deselected=R.color.lvl5; break;
	        case 6:  bkg_resid_deselected=R.color.lvl6; break;
	        case 7:  bkg_resid_deselected=R.color.lvl7; break;
	        case 8:  bkg_resid_deselected=R.color.lvl8; break;
	        case 9:  bkg_resid_deselected=R.color.lvl9; break;
	        case 10: bkg_resid_deselected=R.color.lvl10; break;
	        default: bkg_resid_deselected=R.color.lvl0; break;
		}

        super.setBackgroundResource(bkg_resid_deselected);
	}
	
	public void select() {
		super.setBackgroundResource(bkg_resid_selected);
	}
	
	public void deselect() {
		super.setBackgroundResource(bkg_resid_deselected);
	}
	
	//getters and setters
	
	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}
	
	public int getBkg_resid_selected() {
		return bkg_resid_selected;
	}

	public void setBkg_resid_selected(int bkg_resid_selected) {
		this.bkg_resid_selected = bkg_resid_selected;
	}

	public int getBkg_resid_deselected() {
		return bkg_resid_deselected;
	}

	public void setBkg_resid_deselected(int bkg_resid_deselected) {
		this.bkg_resid_deselected = bkg_resid_deselected;
	}

	//override
}
